/*
 * @(#)RuleActionSetAction.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.rules.action;

import java.util.List;

import org.mandarax.eca.Action;
import org.mandarax.eca.ActionException;

import com.dcivision.framework.TextUtility;
import com.dcivision.framework.Utility;

/**
 * <p>Class Name:  RuleActionSetAction </p>
 * <p>Description: This action implement to invoke multi-action by a action. </p>
 * 
 * @see org.mandarax.eca.Action
 * @author        Tony Chen
 * @company       DCIVision Limited
 * @creation date 26/07/2005
 * @version       $Revision: 1.4 $
 */
public class RuleActionSetAction implements RuleAction {

	private Object target = null;
  private String ruleName = "";
  private List actions = null;

  public RuleActionSetAction(){
    super();
  }

  public RuleActionSetAction ( List actions ) {
    this.actions = actions;
  }

  public Object getTarget() {
    return target;
  }

  public void setTarget(Object target) {
    this.target = target;
  }

  public List getActions(){
    return this.actions;
  }

  public void setActions(List actions){
    this.actions = actions;
  }

  public void perform(Object[] param) throws ActionException {
    if (!Utility.isEmpty(actions)){
      for ( int i = 0 ; i < actions.size() ; i++ ){
        ((Action)actions.get(i)).perform(param);
      }
    }
  }

  public String toString() {
  	if(Utility.isEmpty(actions)){
  		return "";
  	}
    return TextUtility.join(",", actions);  // display all the action, separated by comma
  }

  public String getRuleName() {
    return ruleName;
  }

  public void setRuleName(String ruleName) {
    this.ruleName = ruleName;
  }
}
